package com.itheima.Test.TreeSet;

public class Student1 implements Comparable<Student1>{
    private String name;
    private int chinese;
    private int math;
    private int english;

    public Student1() {
    }

    public Student1(String name, int chinese, int math, int english) {
        this.name = name;
        this.chinese = chinese;
        this.math = math;
        this.english = english;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getChinese() {
        return chinese;
    }

    public void setChinese(int chinese) {
        this.chinese = chinese;
    }

    public int getMath() {
        return math;
    }

    public void setMath(int math) {
        this.math = math;
    }

    public int getEnglish() {
        return english;
    }

    public void setEnglish(int english) {
        this.english = english;
    }

    @Override
    public String toString() {
        return "Student1{" +
                "name='" + name + '\'' +
                ", chinese=" + chinese +
                ", math=" + math +
                ", english=" + english +
                '}'+"总分："+getSum();
    }
    public int getSum(){
        return chinese+math+english;
    }

    @Override
    public int compareTo(Student1 o) {
        int result=this.getSum()-o.getSum();
        result=result==0?this.getChinese()-o.getChinese():result;
        result=result==0?this.getMath()-o.getMath():result;
        result=result==0?this.getEnglish()-o.getEnglish():result;
        result=result==0?this.getName().compareTo(o.getName()):result;
        return result;
    }
}
